<template>
	<view class="fororder">
		<block v-for="(item,index) in newdata" :key="index">
			<view class="orderlist">
				<view class="order-top">
					<view class="order-left">时间: {{item.time}}</view>
					<!-- <view class="money">总金额：￥{{item.allmoney}}</view> -->
				</view>
				<view class="ordercont">
					<view class="orderval">
						<text class="vals-top">会议/培训名称</text>
						<view class="vals">{{item.title}}</view>
					</view>
					<view class="ordernub">
						<view class="nubname">参加人数</view>
						<view class="nubshow">{{item.addnum}}</view>
					</view>
				</view>
				<view class="foot">
					<!-- <view class="footleft">
						<view class="fororder" v-if="item.status == '待支付'">
							<text class="beforeleft" >订单支付中</text>
							<text class="topay" @click="topayfn(item.signUps[0].meetingId,item.signUps[0].id,item.vipnub,item.allmoney,item.addnum)">(点击查看支付方式)</text>
						</view>
						<view class="after" v-else>已支付</view>
					</view>
					<view class="footright">
						<view class="beforeright beforeall" v-if="item.status == '待支付'" @click="tochange(item.signUps[0].id,item.signUps[0].meetingId)">修改回执单</view>
						<view class="afterright beforeall" v-else @click="toorder(item.signUps[0].id,item.signUps[0].meetingId)">查看订单</view>
					</view> -->
					<view class="footleft">
						<view class="fororder" v-if="item.status == '待支付'">
							<text class="beforeleft" >已报名</text>
							<text class="topay" @click="topayfn(item.signUps[0].meetingId,item.signUps[0].id,item.vipnub,item.allmoney,item.addnum)">(点击查看支付方式)</text>
						</view>
						<view class="after" v-else>已报名</view>
					</view>
					<view class="footright">
						<view class="beforeright beforeall" v-if="item.status == '待支付'" @click="tochange(item.signUps[0].id,item.signUps[0].meetingId)">修改回执单</view>
						<view class="afterright beforeall" v-else @click="toorder(item.signUps[0].id,item.signUps[0].meetingId)">查看订单</view>
					</view>
				</view>
			</view>
		</block>
	</view>
</template>

<script>
	import {common} from '@/common/publish.js';
	import {mapState,mapMutations} from 'vuex';
	export default {
		data() {
			return {
				userInfo:{},
				lvarr:['A','AA','AAA'],
				newdata:[]
			};
		},
		onLoad(event) {
			var that = this;
			uni.getStorage({
				key: 'uerInfo',
				success(res) {
					that.userInfo=res.data;
				}
			});
			if(this.islogin){
				this.getlist()
			}
			
		},
		methods: {
			tochange(signupid,meetingid){
				uni.navigateTo({
					url: '/pages/meetingchange/meetingchange?signupid='+signupid+'&meetingid='+meetingid
				});
			},
			toorder(signupid,meetingid){
				uni.navigateTo({
					url: '/pages/meetingorderinfo/meetingorderinfo?signupid='+signupid+'&meetingid='+meetingid
				});
			},
			topayfn(meetingids,signupid){
				uni.navigateTo({
					url: '/pages/meetingpay/meetingpay?meetingid='+ meetingids +'&signupid='+signupid
				});
			},
			getlist(){
				var that = this;
				//console.log(JSON.stringify(that.userInfo))
				uni.request({
					url: common.localurl+'/api/pc/order.json' , 
					data: {
						unionid: that.userInfo.unionId
					},
					success: (res) => {
						//console.log(JSON.stringify(res.data))
						that.newdata = res.data;
						//计算人数，以及钱
						if(res.data.length>0){
							for(var i=0;i<res.data.length;i++){
								that.newdata[i].time = common.format(that.newdata[i].time)
								that.getlv(that.newdata[i])
							}
						}
					}
				});
			},
			getlv(datas){
				var that = this;
				uni.request({
					url: common.localurl+'/api/lv/queryLv.json' ,
					data: {
						title: datas.signUps[0].invoiceTitle
					},
					success: (res) => {
						//获取级别
						var lv = ''
						//var lv = res.data.level?res.data.level:1;
						var vipnub = 1;
						if(res.data.level){
							lv = 'type'+that.lvarr[res.data.level-1]
							vipnub = datas[lv]
						}
						datas.vipnub = vipnub;
						that.getnub(datas,vipnub)
					}
				});
			},
			getnub(datas,vipnub){
				var that = this;
				uni.request({
					url: common.localurl+'/api/pc/attCount.json' ,
					data: {
						signUpId: datas.signUps[0].id
					},
					success: (res) => {
						//人数
						datas.addnum = res.data;
						var allmoney= datas.money*datas.addnum*vipnub;
						datas.allmoney=parseInt(allmoney*100)/100;
						this.$forceUpdate();
					}
				});
			}
		},
		computed:{
			...mapState(['islogin'])
		}
	}
</script>

<style lang="scss">
	@import "@/common/publish.scss";
	page {
		background-color: $bgcolor;
	}
	.orderlist{
		margin-top:20upx;
		background-color: #fff;
		width:750upx;
	}
	.order-top{
		box-sizing:border-box;
		width:750upx;
		border-bottom:1px solid #ccc;
		font-size:30upx;
		color:#333;
		height:80upx;
		line-height:80upx;
		padding:0 24upx;
		display: flex;
		flex-direction:row;
		flex-wrap:nowrap ;
		justify-content:space-between;
		align-items:flex-start;
	}
	.money{
		color:red;
		line-height:80upx;
		font-size:28upx;
	}
	.ordercont{
		padding:0 24upx;
		box-sizing:border-box;
		display: flex;
		flex-direction:row;
		flex-wrap:nowrap ;
		justify-content:space-between;
		align-items:flex-start;
	}
	.orderval{
		flex:1;
		padding-right:30upx;
		border-right:1px solid #ccc;
	}
	.ordernub{
		width:200upx;
	}
	.vals-top,.nubname{
		font-size:28upx;
		line-height:80upx;
		text-align:left;
		color:$titlecolor;
	}
	.vals,.nubshow{
		font-size:28upx;
		line-height:46upx;
		height:92upx;
		color:$timecolor;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		padding-bottom:10upx;
	}
	.nubshow,.nubname{
		text-align:center;
	}
	.nubshow{
		line-height:50upx;
	}
	.foot{
		font-size:30upx;
		line-height:80upx;
		display: flex;
		flex-direction:row;
		flex-wrap:wrap ;
		justify-content:space-between;
		align-items:flex-start;
		color:$titlecolor;
		padding:0 24upx;
		border-top:1px solid #ccc;
	}
	.fororder{
		vertical-align: middle;
	}
	.topay{
		color:red;
		font-size:28upx;
		vertical-align: middle;
	}
	.beforeall{
		font-size:28upx;
		color:$titlecolor;
		border:1px solid $bgcolor;
		line-height:60upx;
		margin-top:10upx;
		height:60upx;
		text-align:center;
		width:200upx;
		border-radius:4upx;
	}
</style>
